// 基本面板组件
<template>
  <el-card body-style="padding:2px 5px 2px 5px" id="my-panel-x">
    <el-row class="panel-header" type="flex" justify="space-between" slot="header">
      <span class="header-title">{{configs.labelText}}</span>
      <div
        v-show="configs.showMore===false?false:true"
        title="查看更多"
        class="header-more"
        @click="toDetial"
      >
        <i class="el-icon-more"></i>
      </div>
    </el-row>
    <slot name="custom-body"></slot>
    <div class="list-body-content" v-if="configs.mode==='list'">
      <el-row
        class="list-item"
        v-for="(item, index) in configs.data"
        :key="index"
        @click="triggerEventDetail(index)"
      >
        <el-col :span="14">
          <div
            :class="(item.isread?'isread':'')"
            @click="triggerEventDetail(index)"
            style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis;"
          >{{item[configs.columns.main]}}</div>
        </el-col>
        <el-col :span="8">
          <div
            :class="(item.isread?'isread':'')"
            @click="triggerEventDetail(index)"
            style="text-align:right"
          >{{item[configs.columns.sub]}}</div>
        </el-col>
        <el-col :span="2" style="text-align:right">
          <div @click="triggerEventDetail(index)" class="el-icon-arrow-right" id="icon"></div>
        </el-col>
      </el-row>
    </div>
  </el-card>
</template>

<script>
export default {
  name: "panelX",
  props: {
    configs: {
      type: Object,
      default() {
        return {
          labeltxt: "",
          linktxt: "",
          linkpathtxt: "",
          contentmode: "",
          data: {
            notice_title: "",
            notice_type: "",
            notice_path: ""
          }
        };
      }
    }
  },
  data: function() {
    return {};
  },

  mounted() {
    console.log("panel mounted");
    this.$emit("ready");
  },

  methods: {
    toDetial: function() {
      this.$router.push({ path: this.configs.mainPath });
    },
    triggerEventDetail: function(index) {
      // this.$router.push({path:item.path,query:item})
      let item = this.configs.data[index];
      this.$emit("toSubModule", index);
      //this.$router.push({path:'/main/index_detail',query:item})
    }
  }
};
</script>

<style lang="less" scoped>
// 根容器
@c-primary: #1296db;
@c-primary-light: #9bc8f6;
#my-panel-x {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  color: black;
  height: 100%;

  .panel-header {
    box-sizing: border-box;
    height: 30px;
    .header-title {
      font-size: 11pt;
      border-bottom: 2px @c-primary solid;
    }
    .header-more {
      color: @c-primary-light;
      border-radius: 50%;
      border: 1px @c-primary-light solid;
      height: 20px;
      width: 20px;
      margin-bottom: 8px;
      vertical-align: middle;
      i {
        line-height: 20px;
        font-size: 14px;
      }
    }
    .header-more:hover {
      color: @c-primary;
      border: 1px @c-primary solid;
      cursor: pointer;
    }
  }

  .list-body-content {
    height: 100%;

    .list-item {
      line-height: 35px;
      border-bottom: 1px solid #ebeef5;
      display: flex;
      align-items: center;
      padding: 0px 5px;
      font-size: 10pt;
      .el-col {
        text-align: left;
        background-color: transparent;
      }

      .isread {
        color: #c0c4cc;
      }
    }
    .list-item:hover {
      color: @c-primary;
      cursor: pointer;
      background-color: #f5f7fa;
    }
  }
}
.text {
  font-size: 14px;
}
.item {
  margin-bottom: 18px;
}
</style>

<style lang="less">
#my-panel-x {
  .el-card__header {
    padding: 5px 5px 0px 5px;
    background-color: #f7faff;
  }

  .el-card__body {
    height: calc(~"100% - 41px");
    overflow: auto;
  }

  .el-card__body::-webkit-scrollbar {
    width: 5px;
  }

  .el-card__body::-webkit-scrollbar-thumb {
    /*滚动条中的滚动块*/
    border-radius: 10px;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
    background: #535353;
  }

  .el-card__body::-webkit-scrollbar-track {
    /*滚动条里面的轨道*/
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    background: #ededed;
  }
}
</style>
